package com.example.demo.moduel.controller;

import com.example.demo.moduel.entity.Worker;
import com.example.demo.moduel.service.WorkerService;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("api/worker")
public class WorkerController {
       @Autowired
       private WorkerService workerService;


       @RequestMapping("/getWorker")
       @ResponseBody
       public Worker getWorkerById(@RequestParam(required = false) Long id) {
              if ( id == null || id <= 0 ) {
                     id = 1L;
              }
              return workerService.getWorkerById(id);
       }
}
